package com.cloud.encrypting_cloud_storage.config;

import com.cloud.encrypting_cloud_storage.interceptor.SimpleAuthenticationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author leon
 * @Description: TODO(mvc配置)
 * @date 2022年04月08日 20:11
 */
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {
    @Bean
    SimpleAuthenticationInterceptor simpleAuthenticationInterceptor(){
        return new SimpleAuthenticationInterceptor();
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(simpleAuthenticationInterceptor())
                // 对所有进行拦截，包括静态资源
                // .addPathPatterns()是对那些路径进行拦截，
                .addPathPatterns("/stores/**");

    }
}
